package com.shms.service.impl;

import java.util.List;

import com.shms.bean.GroupOfGrade;
import com.shms.dao.ShGradeDao;
import com.shms.entity.ShClass;
import com.shms.entity.ShGrade;
import com.shms.service.ShGradeService;
/**
 * 文件名：ShGradeServiceImpl.java
 * 编写者：赵振东
 * 创建时间：2013-3-14
 * 简要描述：
 * 
 */
public class ShGradeServiceImpl implements ShGradeService {

	private ShGradeDao shGradeDao;
	@Override
	public GroupOfGrade queryGrade(GroupOfGrade groupOfGrade) {
		if (groupOfGrade.getType().equals("forward")) {
			int currentPage = groupOfGrade.getCurrentPage() - 2;
			groupOfGrade.setCurrentPage(currentPage);
		}
		return shGradeDao.queryGrade(groupOfGrade);
	}
	public void setShGradeDao(ShGradeDao shGradeDao) {
		this.shGradeDao = shGradeDao;
	}
	@Override
	public boolean batchDelete(Integer[] ids) {
		return this.shGradeDao.batchDelete(ids);
	}
	@Override
	public boolean saveGrades(ShGrade shGrade) {
		boolean rtn = true;
		if (shGrade.getGid() == 0) {
			rtn = shGradeDao.saveGrades(shGrade);
		} else {
			rtn = shGradeDao.updateGrades(shGrade);
		}
		return rtn;
	}
	@Override
	public ShGrade queryById(ShGrade shGrade) {
		return shGradeDao.queryById(shGrade);
	}
	public List<ShGrade> queryAllGname(){
		return shGradeDao.queryAllGname();
	}
	@Override
	public List<ShClass> queryClassesById(ShGrade shGrade) {
		return shGradeDao.queryClassesById(shGrade);
	}
}
